package com.stt.order.design.strategy.impl;

import com.stt.order.model.Order;
import com.stt.order.design.strategy.PromotionStrategy;

import java.math.BigDecimal;

/**
 * 折扣优惠策略实现类
 * 实现折扣的优惠计算
 */
public class DiscountPromotionStrategy implements PromotionStrategy {

    @Override
    public BigDecimal apply(Order order, BigDecimal amount) {
        // 判断是否符合折扣条件
        if (amount.compareTo(new BigDecimal("1000")) >= 0) {
            // 满1000减100
            return amount.subtract(new BigDecimal("100"));
        }
        return amount;
    }

    @Override
    public String getType() {
        return "DISCOUNT";
    }
} 